package ynwx.libaray.utils;

import android.util.Log;

// http://www.jianshu.com/p/325e8f025c98
public class LogUtil {

    public static final String TAG = "ynwx.";

    public static final int VERBOSE = 1;

    public static final int DEBUG = 2;

    public static final int INFO = 3;

    public static final int WARN = 4;

    public static final int ERROR = 5;

    public static final int NOTHING = 6;

    public static final int LEVEL = VERBOSE;

    public static void v(Object target, String msg) {
        if (LEVEL <= VERBOSE) {
            Log.v(TAG + target.getClass().getSimpleName(), msg);
        }
    }

    public static void d(Object target, String msg) {
        if (LEVEL <= DEBUG) {
            Log.d(TAG + target.getClass().getSimpleName(), msg);
        }
    }

    public static void i(Object target, String msg) {
        if (LEVEL <= INFO) {
            Log.i(TAG + target.getClass().getSimpleName(), msg);
        }
    }

    public static void w(Object target, String msg) {
        if (LEVEL <= WARN) {
            Log.w(TAG + target.getClass().getSimpleName(), msg);
        }
    }

    public static void e(Object target, String msg) {
        if (LEVEL <= ERROR) {
            Log.e(TAG + target.getClass().getSimpleName(), msg);
        }
    }

    public static void v(Object target, String msg, Throwable tr) {
        if (LEVEL <= VERBOSE) {
            Log.v(TAG + target.getClass().getSimpleName(), msg, tr);
        }
    }

    public static void d(Object target, String msg, Throwable tr) {
        if (LEVEL <= DEBUG) {
            Log.d(TAG + target.getClass().getSimpleName(), msg, tr);
        }
    }

    public static void i(Object target, String msg, Throwable tr) {
        if (LEVEL <= INFO) {
            Log.i(TAG + target.getClass().getSimpleName(), msg, tr);
        }
    }

    public static void w(Object target, String msg, Throwable tr) {
        if (LEVEL <= WARN) {
            Log.w(TAG + target.getClass().getSimpleName(), msg, tr);
        }
    }

    public static void e(Object target, String msg, Throwable tr) {
        if (LEVEL <= ERROR) {
            Log.e(TAG + target.getClass().getSimpleName(), msg, tr);
        }
    }

}
